# Contributor: André Klitzing <aklitzing@@gmail.com>
# Maintainer: André Klitzing <aklitzing@gmail.com>
pkgname=croc
pkgver=9.6.15
pkgrel=0
pkgdesc="Easily and securely send things from one computer to another"
url="https://github.com/schollz/croc"
license="MIT"
arch="all"
makedepends="go"
subpackages="$pkgname-bash-completion $pkgname-zsh-completion"
source="https://github.com/schollz/croc/archive/refs/tags/v$pkgver/croc-$pkgver.tar.gz"
options="net" # fetch dependencies

# secfixes:
#   9.1.0-r0:
#     - CVE-2021-31603

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -ldflags "-X github.com/schollz/croc/v${pkgver%%.*}/src/cli.Version=v$pkgver"
}

check() {
	go test ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/

	install -Dm644 src/install/bash_autocomplete \
		"$pkgdir"/usr/share/bash-completion/completions/croc
	install -Dm644 src/install/zsh_autocomplete \
		"$pkgdir"/usr/share/zsh/site-functions/_croc
}

sha512sums="
8ae76dc5029e7adc809b0083e147c57c7249e9fbb07f263a0b10d21539ebfc69c5d9d8e60811cca06bbb313ec9a3a143baaef73f77ca599dc102626dc9fccf29  croc-9.6.15.tar.gz
"
